package cn.newtouch.feignclient;

import cn.newtouch.domian.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

//工厂方式的 ， 托底类
@Component
public class UserFallbackFactory implements FallbackFactory<UserFeignClient> {
    //降级的方法
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public User getById(Long id) {
                return new User(-1L,"熔断了","熔断了，服务中止！！");
            }
        };
    }
}